const CODE: [char; 16] = [
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
];
pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let to_base = to_base as usize;
    // 传入字符串为 xxxxx(yyyy)
    let parts: Vec<&str> = num_str.split('(').collect();
    let base = parts[1].trim_end_matches(')').parse::<usize>().unwrap();

    let mut num = 0;
    for c in parts[0].chars() {
        num = num * base + CODE.iter().position(|&code| code == c).unwrap();
    }

    let mut ret = String::new();
    while num != 0 {
        ret.push(CODE.get((num % to_base) as usize).unwrap().clone());
        num = num / to_base;
    }
    let ret = ret.chars().rev().collect();
    ret
}
